#include <xp/lnx/iptc.h>
#include <xp/bas/time.h>
#include <xp/bas/stdio.h>

int xp_main (int argc, xp_char_t* argv[])
{

	xp_iptc_t iptc;

	if (argc != 3) {
		xp_printf (XP_TEXT("usage: %s table chain\n"), argv[0]);
		return -1;
	}

	if (xp_iptc_open (&iptc, argv[1]) == XP_NULL) {
		xp_printf (XP_TEXT("cannot open table - %s\n"), argv[1]);
		return -1;
	}

	if (xp_iptc_zero_chain (&iptc, argv[2]) == -1) {
		xp_printf (XP_TEXT("cannot zero chain - %s\n"), argv[2]);
		return -1;
	}

	/*
	if (xp_iptc_delete_entry (&iptc, argv[2], XP_TEXT("ACCEPT"),
		0, 0xFFFFFF00, 0, 0xFFFFFF00) == -1) {
		xp_printf (XP_TEXT("cannot delete an entry\n"));
		return -1;
	}
	*/
	if (xp_iptc_flush_chain (&iptc, argv[2]) == -1) {
		xp_printf (XP_TEXT("cannot flush chain - %s\n"), argv[2]);
		return -1;
	}

	if (xp_iptc_delete_chain (&iptc, argv[2]) == -1) {
		xp_printf (XP_TEXT("cannot delete chain - %s\n"), argv[2]);
		return -1;
	}

	xp_iptc_close (&iptc);
	return 0;
}
